package org.dromara.article.emnu;

/**
 * 文章类型常量
 */
public enum ArticleTypeConstants {

    ZHICHANG(1, "职场"),
    YULE(2, "娱乐"),
    QINGGAN(3,"情感");


    /**
     * 类型
     */
    public final Integer type;

    /**
     * 名称
     */
    public final String name;

    ArticleTypeConstants(Integer type, String name) {
        this.type = type;
        this.name = name;
    }

    /**
     * 根据名称返回ID
     *
     * @param name
     * @return
     */
    public static Integer getIdByName(String name) {
        for (ArticleTypeConstants type : ArticleTypeConstants.values()) {
            if (name.equals(type.name)) {
                return type.type;
            }
        }

        return null;
    }

    /**
     * 根据ID返回名称
     *
     * @param category
     * @return
     */
    public static String getNameById(String category) {
        for (ArticleTypeConstants type : ArticleTypeConstants.values()) {
            if (category.equals(String.valueOf(type.type))) {
                return type.name;
            }
        }
        return null;
    }
}
